home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 21 / Cream of the Crop 21 (Terry Blount) (October 1996).iso / editor / auror300.zip / TABS.AML < prev    next >
Text File  |  1996-07-17  |  2KB  |  58 lines

  1. //--------------------------------------------------------------------
  2. // TABS.AML
  3. // Entab/Detab, (C) 1993-1996 by nuText Systems
  4. //
  5. // This macro converts tab characters to spaces (Detab), or converts
  6. // spaces to tab characters (Entab) in the current edit window. The
  7. // conversion is limited to a marked block, if it exists in the edit
  8. // window.
  9. //
  10. // The current tab width (the value of the _TabWidth configuration
  11. // variable) is used as the tab width for the conversion.
  12. //
  13. // This macro will run faster if Undo is turned Off.
  14. //
  15. // Usage:
  16. //
  17. // Select this macro from the Macro List (on the Macro menu), or run it
  18. // from the macro picklist <shift f12>.
  19. //--------------------------------------------------------------------
  20.  
  21. // compile time macros and function definitions
  22. include  bootpath "define.aml"
  23.  
  24. if not objtype? "edit" then
  25.   msgbox "Edit windows only!"
  26.   return
  27. end
  28.  
  29. // mark beginning of undoable group
  30. undobegin
  31.  
  32. // test for a mark in the current window
  33. if mark? then
  34.   if getmarkbuf <> getcurrbuf then
  35.     msgbox "Block not marked in current window"
  36.     return
  37.   end
  38. // create a temporary mark covering the entire file
  39. else
  40.   markline 1 (getlines)
  41.   temp_mark = TRUE
  42. end
  43.  
  44. // check if entab was specified
  45. entab = (arg 3) == 'e'
  46.  
  47. // use built-in tabblock function for both detab and entab
  48. tabblock (if? entab -_TabWidth _TabWidth)
  49. if temp_mark then
  50.   destroymark
  51. end
  52.  
  53. undoend
  54.  
  55. display
  56. say  (if? entab "Entab " "Detab ") +
  57.      (if? not temp_mark "block ") + "done."
  58.